﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Cheetah_Fast_Banking_App.Cryptography;

namespace CFBA_Unit_Test
{
    [TestClass]
    public class DataGenerator
    {
        // use to generate salts and hashes for existing users
        // note: this is the only place these passwords are stored in plain text now!  Hashes are one-way, so if you lose it, you need to change your password.  And right now, there is no "reset forgotten password" option.
        //[TestMethod]
        public void TestMethod1()
        {
            SaltGenerator saltGen = new SaltGenerator();
            SHA256Hasher hasher = new SHA256Hasher();

            string username = "john_doe";
            string isadmin = "false";
            string password = "password";
            string salt = saltGen.GenerateRandomSalt();
            string hashedPassword = hasher.GetHash(password, salt);
            Console.WriteLine(String.Format("name=\"{0}\" isadmin=\"{1}\" salt=\"{2}\"password_hash=\"{3}\">", username, isadmin, salt, hashedPassword));

            username = "james_doe";
            password = "password2";
            salt = saltGen.GenerateRandomSalt();
            hashedPassword = hasher.GetHash(password, salt);
            Console.WriteLine(String.Format("name=\"{0}\" isadmin=\"{1}\" salt=\"{2}\"password_hash=\"{3}\">", username, isadmin, salt, hashedPassword));

            username = "jack_doe";
            password = "password3";
            salt = saltGen.GenerateRandomSalt();
            hashedPassword = hasher.GetHash(password, salt);
            Console.WriteLine(String.Format("name=\"{0}\" isadmin=\"{1}\" salt=\"{2}\"password_hash=\"{3}\">", username, isadmin, salt, hashedPassword));

            // different salt and hashedPassword for Test Data just to prove it works
            username = "john_doe";
            password = "password";
            salt = saltGen.GenerateRandomSalt();
            hashedPassword = hasher.GetHash(password, salt);
            Console.WriteLine(String.Format("name=\"{0}\" isadmin=\"{1}\" salt=\"{2}\"password_hash=\"{3}\">", username, isadmin, salt, hashedPassword));
        }
    }
}
